package com.me.modules.srm.service.impl;

import com.me.modules.common.common.Constant;
import com.me.modules.common.page.Page;
import com.me.modules.common.page.PageHelper;
import com.me.modules.common.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.me.modules.srm.dao.SrmInfoDao;
import com.me.modules.srm.entity.SrmInfoEntity;
import com.me.modules.srm.service.SrmInfoService;



@Service("infoService")
public class SrmInfoServiceImpl implements SrmInfoService {
	@Autowired
	private SrmInfoDao infoDao;

	@Override
	public SrmInfoEntity queryObject(Long id){
		return infoDao.queryObject(id);
	}

	@Override
	public List<SrmInfoEntity> queryList(Map<String, Object> map){
		return infoDao.queryList(map);
	}

    @Override
    public List<SrmInfoEntity> queryListByBean(SrmInfoEntity entity) {
        return infoDao.queryListByBean(entity);
    }

	@Override
	public int queryTotal(Map<String, Object> map){
		return infoDao.queryTotal(map);
	}

	@Override
	public int save(SrmInfoEntity info){
		info.setStatus("1");
		info.setStartTime(new Date());
		info.setReqId(UserUtils.getCurrentUserId());

		return infoDao.save(info);
	}

	@Override
	public int update(SrmInfoEntity info){
        return infoDao.update(info);
	}

	@Override
	public int delete(Long id){
        return infoDao.delete(id);
	}

	@Override
	public int deleteBatch(Long[] ids){
        return infoDao.deleteBatch(ids);
	}


	@Override
	public Page<SrmInfoEntity> findPage(SrmInfoEntity info, int pageNum) {
		PageHelper.startPage(pageNum, Constant.pageSize);
		infoDao.queryList(info);
		return PageHelper.endPage();
	}
}
